﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PeisongWeb.controls
{
    public partial class sellerHeader : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (logic.customer.userId != 0)
                {
                    DAL.CustomerEntity customer = logic.customer.getById(logic.customer.userId);
                    lblUserName.Text = customer.Username;
                    if (customer != null)
                    {
                        if (customer.CompanyId != 0)
                        {
                            DAL.CompanyEntity company = logic.company.getById(customer.CompanyId);
                            if (company != null)
                            {
                                lblCompanyName.Text = company.Company;
                            }
                        }
                    }
                    LoginedPanel.Visible = true;
                    topNav.Visible = true;
                }
                else
                {
                    LoginedPanel.Visible = false;
                    topNav.Visible = false;
                }
            }
        }

        protected void linkLogout_Command(object sender, CommandEventArgs e)
        {
            logic.customer.logout();
        }
    }
}